<!doctype html>
<html ng-app="fish">

<head>
    <meta charset="utf-8">
    <title>模板</title>
    <style>

    </style>
    <script src="angular.js"></script>
    <script>
    // var app = angular.module('test', []);

    // app.controller('aaa', function($scope) {
    //     $scope.arr = [{
    //         name: 'xxx鞋',
    //         price: 12.8,
    //         count: 1
    //     }, {
    //         name: 'xxx衣服',
    //         price: 250,
    //         count: 2
    //     }, {
    //         name: 'xxx帽子',
    //         price: 25.6,
    //         count: 8
    //     }];

    //     $scope.total = function() {
    //         var result = 0;

    //         for (var i = 0; i < $scope.arr.length; i++) {
    //             result += $scope.arr[i].price * $scope.arr[i].count;
    //         }

    //         return result;
    //     };
    // });

    var myapp = angular.module('fish', []);
    myapp.controller('bbb', function($scope) {
        $scope.arr = [{
            name: 'xxx鞋',
            price: 12,
            count: 1
        }, {
            name: 'xxx衣服',
            price: 250,
            count: 2
        }, {
            name: 'xxx帽子',
            price: 25,
            count: 8
        }];
        $scope.total = function() {
            var result = 0;
            for (var i = 0; i < $scope.arr.length; i++) {
                result += $scope.arr[i].price * $scope.arr[i].count;
            }
            return result;
        }
    })
    </script>
</head>

<body ng-controller="bbb">
    <ul>
        <li ng-repeat="item in arr">
            <h2>{{item.name}}</h2> 单价：{{item.price}}
            <input type="number" ng-model="item.count" />
            <br> 总价：{{item.price*item.count}}
        </li>
    </ul>
    总价：{{total()}}
</body>

</html>
